import api from "api/api.js"
import consts from "utils/consts.js"
//app.js
App({
  onLaunch: function () {
    wx.login({
      success: function (res) {
        api.login({
          mothed: "get",
          data: {
            code: res.code
          },
          success: function (resp) {
            if (resp.code == 0) {
              getApp().globalData.openid = resp.data.user.openid
              getApp().globalData.userInfo = resp.data.user
              getApp().globalData.userConf = resp.data.conf

              console.log(getApp().globalData)
              wx.switchTab({
                url: "/pages/my/course-fixed/index"
              })
            } else {
              getApp().globalData.openid = resp.message
              wx.switchTab({
                url: "/pages/my/index"
              })
            }
          }
        })
      }
    })
  },
  globalData: {
    openid: null,
    userInfo: null,
    userConf: null
  }
})